package pl.omega.selenium.applogic2;

import java.util.List;

import pl.omega.selenium.applogic.FilmHelper;
import pl.omega.selenium.model.Film;

public class FilmHelper2 extends DriverBasedHelper implements FilmHelper {

	public FilmHelper2(ApplicationManager2 manager) {
		super(manager.getWebDriver());
	}

	@Override
	public void create(Film film) {
		pages.filmListPage.clickAddFilmPage();
		pages.filmAddPage.ensurePageLoaded()
			.setName(film.getTitle())
			.setYear(film.getYear())
			.clickSubmitButton().ensurePageLoaded()
			.clickHomePage();
	}

	@Override
	public void delete(Film film) {
		pages.filmListPage.clickFilm()
			.clickDeleteButton();
	}

	@Override
	public List<Film> search(String title) {
		return pages.filmListPage
			.search(title)
			.getFilms();
	}

	@Override
	public Integer getFilmCount() {
		return pages.filmListPage.ensurePageLoaded()
					.getFilmCount();
	}

}
